package leetcode;

import java.util.Arrays;

/**
 * 分发饼干
 */
public class Leetcode455 {
    public int findContentChildren(int[]  children, int[] cookies) {
        children = sort(children);
        cookies = sort(cookies);
        int child = 0;
        int cookie = 0;
        while (child < children.length && cookie < cookies.length) {
            if (children[child] < children[cookie]) {
                ++child;
            }
            ++cookie;
        }
        return child;
    }

    public int[] sort(int[] num) {
        Arrays.sort(num);
        return num;
    }

}
